//
//  AppDelegate+RongCloud.m
//  WeClubs
//
//  Created by KevinWang on 17/6/19.
//  Copyright © 2017年 Zed. All rights reserved.
//

#import "AppDelegate+RongCloud.h"
#import <RongIMLib/RongIMLib.h>
#import "ThirdPartKeyDefine.h"


@implementation AppDelegate (RongCloud)

- (void)RongCloudConfig{
    //init
    [[RCIMClient sharedRCIMClient] initWithAppKey:TestRongCloudAppKey];
    
    [HTTPRequest POST:kIm_get_token parameter:nil success:^(id resposeObject) {
        NSString *im_token = resposeObject[@"data"][@"im_token"];
        [[RCIMClient sharedRCIMClient] connectWithToken:im_token success:^(NSString *userId) {
            ZLog(@"登陆成功。当前登录的用户ID：%@", userId);
        } error:^(RCConnectErrorCode status) {
            ZLog(@"登陆的错误码为:%ld", (long)status);
        } tokenIncorrect:^{
            ZLog(@"token错误");
        }];
    } failure:^(NSError *error) {
        ZLog(@"%@",error);
    }];
    
    //test user:123   kevin
    //test user:456   rose
    //test group:xx00 xx00
//    [[RCIMClient sharedRCIMClient] connectWithToken:@"T2b36MvGDB/6adXlADaKLqOqXb3NaJhSa89bkKTJ3co8mSne93Q3uIIgXjDOcFjnIN2FTLdGpiA=" success:^(NSString *userId) {
//        ZLog(@"登陆成功。当前登录的用户ID：%@", userId);
//    } error:^(RCConnectErrorCode status) {
//        ZLog(@"登陆的错误码为:%ld", (long)status);
//    } tokenIncorrect:^{
//        ZLog(@"token错误");
//    }];
}

@end
